local ZEjiuyuan = fk.CreateSkill {

  name = "ZEjiuyuan$",

  tags = { Skill.Lord },
}

Fk:loadTranslationTable{
    ["ZEjiuyuan$"] = "救援",
    [":ZEjiuyuan$"] = "主公技，其他与你相同势力角色于其回合内回复体力时，若其体力值大于等于你，则其可以改为令你回复1点体力，然后其摸一张牌。",
    ["#ZEjiuyuan-ask"] = "救援：你可以改为令 %dest 回复1点体力，然后你摸一张牌",
}

ZEjiuyuan:addEffect(fk.PreHpRecover, {
  name = "ZEjiuyuan$",
  anim_type = "support",
  events = {fk.PreHpRecover},
  can_trigger = function(self, event, target, player, data)
    return
      target ~= player and
      player:hasSkill(ZEjiuyuan.name) and
      target.kingdom == player.kingdom and
      target.phase ~= Player.NotActive and
      target.hp >= player.hp and
      player:isWounded()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(target, {
      skill_name = ZEjiuyuan.name,
      prompt = "#ZEjiuyuan-ask::"..player.id,
    }) then
      room:doIndicate(target, {player})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:recover{
      who = player,
      num = 1,
      skillName = ZEjiuyuan.name,
      recoverBy = target,
    }
    target:drawCards(1, ZEjiuyuan.name)
    return true
  end,
})

return ZEjiuyuan